home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
UPC12BS1.ZIP
/
UUCICO
/
COMM.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-05-30
|
52KB
|
1,663 lines
TITLE COMM
PAGE 83,132
; $Id: comm.asm 1.7 1993/05/31 01:39:23 ahd Exp $
;
; $Log: comm.asm $
;; Revision 1.7 1993/05/31 01:39:23 ahd
;; Add return to spin loop (fix by Bill Plummer)
;; Drop FIFO size to 8
;;
;; Revision 1.4 1993/05/30 00:20:02 ahd
;; Insert minor delay to allow slow modems to catch up
;;
;; Revision 1.2 1992/12/18 12:08:25 ahd
;; Add Plummer's fix for bad TASM assemble of com_errors
;;
;
; 14-Jun-93 plummer Add RET to spinloop routine
; 14-Jun-93 plummer Set FIFO thresholds to 8 rather than 16 bytes
; 18-May-93 plummer Define IO$DELAY and use in UART type determination
; 16-May-93 plummer Debug code to printout UART type
; 22-Apr-93 plummer Make case consistent in "TBuff" so it links properly
; 2-Dec-92 plummer Fix com_errors() again. Change got lost.
; Fix com_errors() to avoid problems with tasm. Plummer, 11/16/92
; 8259 EOI issued after interrupts serviced. Plummer, 3/25/92
; Fix botch in Set_Baud. Plummer, 3/20/92
; Put in Gordon Lee's cure from dropped interrupts. Plummer, 3/19/92
; TEMPORARY ioctl_com(). Plummer, 3/9/92.
; Clear OUT2 bit in UART. Some machines use it so enable IRQ. Plummer, 3/9/92
; Release send buffer if we can't assign a recv buffer. Plummer, 3/9/92
; Move EQU's outside of SP_TAB struc definition. ahd, 3/8/92.
; ahd changes: short jmp's out of range in INST, OPEN ??? (ahd, 3/?/92)
; open_com() leaves DTR unchanged so Drew's autobaud works. Plummer, 3/2/92
; Missing DX load in close_com() -- FIFO mode not cleared. Plummer, 3/2/92
; C calling convention does not require saving AX, BX, CX, DX. Plummer 2/23/92
; Flush consideration of the PC Jr. Wm. W. Plummer, 2/15/92
; Cleanup PUSHF/POPF and CLI/STI useage. Wm. W. Plummer, 2/15/92
; Make SENDII have Giles Todd's change. Wm. W. Plummer, 2/15/92
; Changes to Giles Todd's code to support dynamic buffers. Plummer, 2/3/92
; 26 Jan 92 Giles Todd Prime THR for UARTs which do not give a Tx empty
; interrupt when Tx interrupts are enabled.
; S_SIZE & R_SIZE may be set with -D to MASM. Wm. W. Plummer, 1/19/92
; Assign buffers dynamically. Wm. W. Plummer, 1/19/92
; Unfix byte length -- I screwed up. Wm. W. Plummer, 1/15/92
; Fix byte length with specific PARITY select. Wm. W. Plummer, 1/13/92
; Buffers up to 4096 per AHD. Wm. W. Plummer, 1/1/92
; Always use FIFO length of 16 on send side. Wm. W. Plummer, 12/30/91.
; Init DSR and CTS previous state from current status. Wm. Plummer, 12/30/91.
; UUPC conditional to disable v.24. Wm. W. Plummer, 12/30/91.
; Buffer sizes up to 2048 per ahd. Wm. W. Plummer, 12/15/91.
; dtr_on() switches to D connection if CTS&DSR don't come up. WWP, 12/15/91.
; New dtr_on() logic. Wm. W. Plummer, 12/11/91
; Fix bad reg. per report from user. Wm. W. Plummer, 12/11/91
; Semicolon before control-L's for MASM 5.00 per ahd. Wm. W. Plummer, 12/8/91
; Use AHD's handling of COM ports. Wm. W. Plummer, 11/29/91
; Buffer sizes reduced and required to be 2**N. Wm. W. Plummer, 11/11/91
; Accomodate V.24 requirements on DTR flaps. Wm. W. Plummer 10/15/91
; Revised DTR_ON_COM to solve user problem. Wm. W. Plummer, 10/3/91
; Make time delays independent of CPU speed. Wm. W. Plummer, 9/16/91
; Use interrupts to trace CD, DSR, Wm. W. Plummer, 9/16/91
; Remove modem control from TXI. Wm. W. Plummer, 9/13/91
; Completely redo the XOFF/XON logic. Too many races before. Wm. W. Plummer
; Revise interrupt dispatch for speed & function. William W. Plummer, 9/12/91
; Merge in ahd's changes to flush control Q,S when received as flow control
; SEND buffer allows one byte for a SENDII call. Avoids flow control
; lockups. - William W. Plummer, 8/30/91
; Support for NS16550A chip with SILO - William W. Plummer, 8/30/91
; Add modem_status() routine - William W. Plummer, 7/2/91
; Put wrong code under AHD conditional - William W. Plummer, 7/2/91
; Change TITLE, repair bad instr after INST3 - William W. Plummer, 7/1/91
; Modified to use COM1 thru COM4 - William W. Plummer, 2/21/91
; Eliminate (incomplete) support for DOS1 - William W. Plummer, 11/13/90
; Changes may be copied and modified with no notice. Copyrights and copylefts
; are consider silly and do not apply. -- William W. Plummer
; modified to use MSC calling sequence. jrr 3/86
;****************************************************************************
; Communications Package for the IBM PC, XT, AT and strict compatibles.
; May be copied and used freely -- This is a public domain program
; Developed by Richard Gillmann, John Romkey, Jerry Saltzer,
; Craig Milo Rogers, Dave Mitton and Larry Afrin.
;
; We'd sure like to see any improvements you might make.
; Please send all comments and queries about this package
; to GILLMANN@USC-ISIB.ARPA
;
; o Supports both serial ports simultaneously
; o All speeds to 19200 baud
; o Compatible with PC, XT, AT
; o Built in XON/XOFF flow control option
; o C language calling conventions
; o Logs all comm errors
; o Direct connect or modem protocol
PAGE;
;
; Buffer sizes -- *** MUST be powers of 2 ****
IFDEF UUPC
R_SIZE EQU 4096
S_SIZE EQU 4096
ENDIF
; If not set above, maybe on assembler command line. But if not, ...
IFNDEF R_SIZE
R_SIZE EQU 512 ; Recv buffer size
ENDIF
IFNDEF S_SIZE
S_SIZE EQU 512 ; Send buffer size
ENDIF
; INTERRUPT NUMBERS
INT_COM1 EQU 0CH ; COM1: FROM 8259
INT_COM2 EQU 0BH ; COM2: FROM 8259
INT_COM3 EQU 0CH ; COM3: FROM 8259
INT_COM4 EQU 0BH ; COM4: FROM 8259
; 8259 PORTS
INTA00 EQU 20H ; 8259A PORT, A0 = 0
INTA01 EQU 21H ; 8259A PORT, A0 = 1
; COM1: & COM3: LEVEL 4
IRQ4 EQU 2*2*2*2 ; 8259A OCW1 MASK, M4=1, A0=0
NIRQ4 EQU NOT IRQ4 AND 0FFH ; COMPLEMENT OF ABOVE
EOI4 EQU 4 OR 01100000B ; 8259A OCW2 SPECIFIC IRQ4 EOI, A0=0
; COM2: & COM4: LEVEL 3
IRQ3 EQU 2*2*2 ; 8259A OCW1 MASK, M3=1, A0=0
NIRQ3 EQU NOT IRQ3 AND 0FFH ; COMPLEMENT OF ABOVE
EOI3 EQU 3 OR 01100000B ; 8259A OCW2 SPECIFIC IRQ3 EOI, A0=0
; FLOW CONTROL CHARACTERS
CONTROL_Q EQU 11H ; XON
CONTROL_S EQU 13H ; XOFF
; MISC.
DOS EQU 21H ; DOS FUNCTION CALLS
;
; ROM BIOS Data Area
;
RBDA SEGMENT AT 40H
RS232_BASE DW 4 DUP(?) ; ADDRESSES OF RS232 ADAPTERS
RBDA ENDS
PAGE;
;
; TABLE FOR EACH SERIAL PORT
;
SP_TAB STRUC
PORT DB ? ; 1 OR 2 OR 3 OR 4
; PARAMETERS FOR THIS INTERRUPT LEVEL
INT_COM DB ? ; INTERRUPT NUMBER
IRQ DB ? ; 8259A OCW1 MASK
NIRQ DB ? ; COMPLEMENT OF ABOVE
EOI DB ? ; 8259A OCW2 SPECIFIC END OF INTERRUPT
; INTERRUPT HANDLERS FOR THIS LEVEL
INT_HNDLR DW ? ; OFFSET TO INTERRUPT HANDLER
OLD_COM_OFF DW ? ; OLD HANDLER'S OFFSET
OLD_COM_SEG DW ? ; OLD HANDLER'S SEGMENT
; ATTRIBUTES
INSTALLED DB ? ; IS PORT INSTALLED ON THIS PC? (1=YES,0=NO)
BAUD_RATE DW ? ; 19200 MAX
CONNECTION DB ? ; M(ODEM), D(IRECT)
PARITY DB ? ; N(ONE), O(DD), E(VEN), S(PACE), M(ARK)
STOP_BITS DB ? ; 1, 2
XON_XOFF DB ? ; E(NABLED), D(ISABLED)
; FLOW CONTROL STATE
HOST_OFF DB ? ; HOST XOFF'ED (1=YES,0=NO)
PC_OFF DB ? ; PC XOFF'ED (1=YES,0=NO)
URGENT_SEND DB ? ; We MUST send one byte (XON/XOFF)
SEND_OK DB ? ; DSR and CTS are ON
; ERROR COUNTS
ERROR_BLOCK DW 8 DUP(?); EIGHT ERROR COUNTERS
; UART PORTS - DATREG thru MSR must be in order shown.
DATREG DW ? ; DATA REGISTER
IER DW ? ; INTERRUPT ENABLE REGISTER
IIR DW ? ; INTERRUPT IDENTIFICATION REGISTER (RO)
LCR DW ? ; LINE CONTROL REGISTER
MCR DW ? ; MODEM CONTROL REGISTER
LSR DW ? ; LINE STATUS REGISTER
MSR DW ? ; MODEM STATUS REGISTER
UART_SILO_LEN DB ? ; Size of a silo chunk (1 for 8250)
;
; BUFFER POINTERS
START_TDATA DW ? ; INDEX TO FIRST CHARACTER IN X-MIT BUFFER
END_TDATA DW ? ; INDEX TO FIRST FREE SPACE IN X-MIT BUFFER
START_RDATA DW ? ; INDEX TO FIRST CHARACTER IN REC. BUFFER
END_RDATA DW ? ; INDEX TO FIRST FREE SPACE IN REC. BUFFER
; BUFFER COUNTS
SIZE_TDATA DW ? ; NUMBER OF CHARACTERS IN X-MIT BUFFER
SIZE_RDATA DW ? ; NUMBER OF CHARACTERS IN REC. BUFFER
; BUFFERS
TBuff DD ? ; Pointer to transmit buffer
RBuff DD ? ; Pointer to receive buffer
SP_TAB ENDS
; SP_TAB EQUATES
; WE HAVE TO USE THESE BECAUSE OF PROBLEMS WITH STRUC
EOVFLOW EQU ERROR_BLOCK ; BUFFER OVERFLOWS
EOVRUN